package com.atguigu.lease.common.context;

/**
 * @author XC
 * @version 1.0
 * @description
 * @knowledge
 */
// 维护 ThreadLocal本地线程对象
public class LoginUserContext {
    private static final ThreadLocal<LoginUser> threadLocal = new ThreadLocal<>();

    // 向 threadLocal对象保存 token负载信息
    public static void set(LoginUser loginUser) {
        threadLocal.set(loginUser);
    }

    // 从 threadLocal对象获取 token负载信息
    public static LoginUser get() {
        return threadLocal.get();
    }

    // 删除 threadLocal对象中保存的 token负载信息
    public static void remove() {
        threadLocal.remove();
    }
}
